package com.jeasonzhao.report.model.chart;

import com.jeasonzhao.commons.utils.Algorithms;

public class DataPointAry extends java.util.Vector<DataPoint>
{
    private static final long serialVersionUID = 1L;
    private String m_strTitle = null;
    public DataPointAry(String strTitle,DataPoint ...points)
    {
        super();
        this.m_strTitle = strTitle;
        if(null != points)
        {
            for(DataPoint pt : points)
            {
                this.add(pt);
            }
        }
    }

    public DataPointAry(String strTitle,java.lang.Iterable<DataPoint> it)
    {
        super();
        this.m_strTitle = strTitle;
        if(null != it)
        {
            for(DataPoint pt : it)
            {
                this.add(pt);
            }
        }
    }

    public String getTitle()
    {
        return m_strTitle;
    }

    public void compress()
    {
        for(int n = 0;n < this.size();n++)
        {
            if(this.elementAt(n) == null)
            {
                this.remove(n);
                n--;
            }
        }
    }

    public String toString()
    {
        return this.getTitle() + "={" + this.toString(",",false) + "}";
    }

    public String toString(String str,boolean appendAtFirst)
    {
        StringBuffer strRet = new StringBuffer();
        for(int n = 0;n < this.size();n++)
        {
            if(str != null && (n > 0 || appendAtFirst))
            {
                strRet.append(str);
            }
            strRet.append(this.elementAt(n));
        }
        return strRet.toString();

    }

    public int hashCode()
    {
        return super.hashCode();
    }

    public boolean equals(Object obj)
    {
        return Algorithms.areEquals(this,obj);
    }
}
